﻿using NUnit.Framework;

namespace NMA.Infrastructure.Tests.Security
{
    using NMA.Infrastructure.Security;

    [TestFixture]
    public class StringHasherTest
    {
        [Test]
        public void Can_hash_string()
        {
            string hashString = "Text for hashing";
            string hash;

            using (StringHasher hasher = new StringHasher())
            {
                hash = hasher.HashString(hashString);

                Assert.AreNotEqual(hash, hashString, "String unchanged by hashing");
                Assert.AreEqual(hasher.HashString("Text for hashing"), hash,
                                "Second hash gave different result");
            }

            using (StringHasher hasher2 = new StringHasher())
            {
                string hash2 = hasher2.HashString(hashString);

                Assert.AreNotEqual(hash, hashString, "String unchanged by hashing");
                Assert.AreEqual(hasher2.HashString("Text for hashing"), hash,
                                "Second hash gave different result");
                Assert.AreEqual(hash2, hash, "Different hashers gave different answers.");
            }
        }
    }
}